#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
多功能工具箱主程序
作者: Xiaoyu
版本: 1.0.0
"""

import os
import sys
import json
from typing import Dict, List, Any

# 添加当前目录到Python路径
current_dir = os.path.dirname(os.path.abspath(__file__))
if current_dir not in sys.path:
    sys.path.insert(0, current_dir)

from core.cli_interface import CLIInterface
from core.plugin_manager import PluginManager
from core.config_manager import ConfigManager


class ToolBox:
    """多功能工具箱主类"""
    
    def __init__(self):
        """初始化工具箱"""
        self.config_manager = ConfigManager()
        self.plugin_manager = PluginManager(self.config_manager)
        self.cli_interface = CLIInterface(self.plugin_manager, self.config_manager)
        
    def run(self):
        """运行工具箱"""
        try:
            # 加载插件
            self.plugin_manager.load_plugins()
            
            # 启动命令行界面
            self.cli_interface.start()
            
        except KeyboardInterrupt:
            print("\n\n感谢使用多功能工具箱！")
            sys.exit(0)
        except Exception as e:
            print(f"程序运行出错: {e}")
            sys.exit(1)


def main():
    """主函数"""
    print("=" * 60)
    print("           多功能工具箱 v1.0.0")
    print("=" * 60)
    
    toolbox = ToolBox()
    toolbox.run()


if __name__ == "__main__":
    main()